R is to RStudio as Git is to GitHub

Cory Whitney (cory.whitney@uni-bonn.de)

Automated version control

Never have I ever:

  • used 'cmd z' or 'ctrl z'
  • came to the office but left the work at home on another machine or USB
  • tried to co-author scripts by emailing files back and forth

Git is an open source version control tool, GitHub is a company that hosts Git repositories in the web and provides a web interface to interact with repos they host.

Git: overview

A better way to:

  • “undo” changes,
  • collaborate than mailing files back and forth, and
  • share code and other scientific work with the world.

plot of chunk unnamed-chunk-1

GitHub: overview

your local repository consists of three “trees” maintained by git. the first one is your Working Directory which holds the actual files. the second one is the Index which acts as a staging area and finally the HEAD which points to the last commit you've made.


plot of chunk unnamed-chunk-2

Git and GitHub: getting stuck

  • If you get stuck, just add “Git” to a search query e.g. a short description of your issue
  • Someone else has also been confused by it and has written about it
  • Thousands of talented programmers who scan the web and answer these problems plot of chunk unnamed-chunk-3

Git and GitHub: basics

Install Git & join Github (if you have not already):

Some useful tips on getting these running from our friends

GitHub: host for your code

GitHub

plot of chunk unnamed-chunk-4

GitHub: intro hello-world

Git: Command line

  • git reset --soft HEAD~1 or commit SHA we undo our last commit, but the changes contained in that commit are not lost

  • git reset --hard HEAD~1 or commit SHA we discard all changes we've made in the working directory

  • git stash
    move the waiting changes out of the queue